package com.killer_jin.core.common.util.vo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;

@Api
public class Result<T> {
    @ApiModelProperty("实际传输的数据")
    private T data;
    @ApiModelProperty
    private Long total = 1L;
    @ApiModelProperty(
            required = true
    )
    private boolean success = true;
    @ApiModelProperty
    private String msg = "操作完成";

    public Result() {
    }

    public static Result genSuccess(String msg) {
        return (new Result()).setSuccess(true).setMsg(msg);
    }

    public static Result genSuccess(Object data, Long total) {
        return (new Result()).setSuccess(true).setData(data).setTotal(total);
    }

    public static Result genFail(String msg) {
        return (new Result()).setSuccess(false).setMsg(msg).setTotal(0L);
    }

    public boolean isSuccess() {
        return this.success;
    }

    public Result setSuccess(boolean success) {
        this.success = success;
        return this;
    }

    public Object getData() {
        return this.data;
    }

    public Result setData(T data) {
        this.data = data;
        return this;
    }

    public String getMsg() {
        return this.msg;
    }

    public Result setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public Long getTotal() {
        return this.total;
    }

    public Result setTotal(Long total) {
        this.total = total;
        return this;
    }
}